package vld

import (
	sqlc "bp/db/sqlc"
	"bp/internal/util"
)

// IsCouponStatus check string is em_coupon_status
func IsCouponStatus(v string) (success bool) {
	switch sqlc.EmCouponStatus(v) {
	case sqlc.EmCouponStatusDraft, sqlc.EmCouponStatusPublished,
		sqlc.EmCouponStatusPaused, sqlc.EmCouponStatusFinished,
		sqlc.EmCouponStatusClosed:
		success = true
	}
	return
}

// IsCouponStatusArray check []string is []em_coupon_status
func IsCouponStatusArray(v []string, emptyIsValid bool) (success bool) {
	if emptyIsValid && len(v) == 0 {
		success = true
		return
	}
	success = util.AllString(v, func(s string) bool {
		return IsCouponStatus(s)
	})
	return
}
